<script setup>
defineProps({
  list: {
    type: Array,
    default: () => []
  }
})

function handleClick(link) {
  if (link && (link.includes('https://') || link.includes('http://'))) {
    window.open(link)
  } else {
    navigateTo(link)
  }
}
</script>

<template>
  <div class="nav-warp">
    <div v-for="item in list" :key="item.name" class="nav-item" @click="handleClick(item.link)">
      <div class="img-warp"><img class="w-20px h-20px ml-16px" :src="`/images/icon/nav/${item.icon}.png`" :alt="item.name" /></div>
      <div class="ml-10px">
        <div class="nav-name">{{ item.name }}</div>
        <div class="nav-text">{{ item.text }}</div>
      </div>
    </div>
  </div>
</template>

<style lang="scss" scoped>
.nav-warp {
  display: flex;
  flex-wrap: wrap;
  width: 600px;
  padding: 20px 0 20px 30px;
  .nav-item {
    width: 180px;
    height: 60px;
    display: flex;
    align-items: center;
    line-height: 60px;
    margin: 0 0 20px 0;
    color: #111111;
    border-radius: 8px;
    cursor: pointer;
    .img-warp {
      position: relative;
      top: -9px;
    }
    div {
      line-height: auto;
    }
    &:hover {
      background: #f0f5ff;
      border-radius: 8px;
      transition: 0.3s;
    }

    .nav-name {
      font-weight: bold;
      line-height: 20px;
    }
    .nav-text {
      color: #777;
      font-size: 12px;
      line-height: 20px;
    }
  }
}
</style>
